%{
#include <string.h>
#include "attr.h"
#include "parse.tab.h"
#define YY_SKIP_YYWRAP
%}
	extern YYSTYPE yylval;
	extern int yywrap() {return 1;}
	extern int isatty();
	int lines = 1;

D       [0-9]
id	[A-Za-z][A-Za-z0-9]*

%%
{D}+		{ECHO;
		yylval.token.num = atoi(yytext);
		return(NUM);}
:=		{ECHO;return(ASG);}
\*\*		{ECHO;return(EXP);}
\.		{ECHO;return(PERIOD);}
[\[\]*+(),:;=-]	{ECHO;return(yytext[0]);}
program		{ECHO;return(PROG);}
begin		{ECHO;return(BEG);}
end		{ECHO;return(END);}
div             {ECHO;return(DIV);}
writeln		{ECHO;return(WRITELN);}
{id}		{ECHO;
		yylval.token.str = (char *) malloc(strlen(yytext)+1);
		strcpy(yylval.token.str,yytext);
		return(ID);
		}
\n		{int c;
		ECHO;
		c = input();
		if (c != EOF) {unput(c); lines++; fprintf(yyout,"%d\t",lines);}
		else yyterminate();
		}
[ \t]		{ECHO;}
[!@#$%^&|?]	{ECHO;
		printf("\nERROR: %c is and illegal character\n",yytext[0]);
		}
%%

